﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChartSharp
{
    public class ExtendedEncoder : BaseEncoder<int>
    {
        private static readonly string _encodingValues = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.";

        protected internal override string Prefix
        {
            get { return "e"; }
        }

        protected internal override string DataSetsSeparator
        {
            get { return ","; }
        }

        protected internal override string NumbersSeparator
        {
            get { return string.Empty; }
        }

        protected override string MissingValue
        {
            get { return "__"; }
        }

        protected override int MinValidValue
        {
            get { return 0; }
        }

        public override int MaxValidValue
        {
            get { return 4095; }
        }

        protected override string EncodeValue(int value)
        {
            int upper = value >> 6;
            int lower = value % 64;
            return string.Format("{0}{1}", _encodingValues[upper], _encodingValues[lower]);
        }
    }
}
